home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / as / dist / gdb-file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-01  |  1.9 KB  |  81 lines

  1. /* gdb_file.c -o/s specific-
  2.    Copyright (C) 1987 Free Software Foundation, Inc.
  3.  
  4. This file is part of GAS, the GNU Assembler.
  5.  
  6. GAS is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10.  
  11. GAS is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with GAS; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include <stdio.h>
  21. #include <sys/types.h>
  22. #include <sys/stat.h>
  23.  
  24. static long file_len;
  25. static FILE *file;
  26. extern long get_len();
  27.  
  28.  
  29. void
  30. gdb_file_begin ()
  31. {
  32. }
  33.  
  34. void
  35. gdb_file_end()
  36. {
  37. }
  38.  
  39. long int            /* Open file, return size. 0: failed. */
  40. gdb_file_size (filename)
  41. char *filename;
  42. {
  43.   struct stat stat_buf;
  44.   void as_perror();
  45.  
  46.   file= fopen (filename, "r");
  47.   if (file == (FILE *)NULL)
  48.     {
  49.       as_perror ("Can't read GDB symbolic information file", filename);
  50.       file_len=0;
  51.     } else {
  52.     (void)fstat (fileno(file), &stat_buf);
  53.     file_len=stat_buf . st_size;
  54.     }
  55.   return ((long int)file_len );
  56. }
  57.  
  58. void                /* Read the file, don't return if failed. */
  59. gdb_file_read (buffer, filename)
  60.      char *    buffer;
  61.      char *    filename;
  62. {
  63.   register off_t    size_wanted;
  64.   void as_perror();
  65.  
  66.   size_wanted = file_len;
  67.   if (fread (buffer, size_wanted, 1, file) != 1)
  68.     {
  69.       as_perror ("Can't read GDB symbolic info file", filename);
  70.       as_fatal ("Failed to read %ld. chars of GDB symbolic information",
  71.         size_wanted);
  72.     }
  73.   if (fclose(file)==EOF)
  74.     {
  75.       as_perror ("Can't close GDB symbolic info file", filename);
  76.       as_fatal ("I quit in disgust");
  77.     }
  78. }
  79.  
  80. /* end: gdb_file.c */
  81.